//
//  JYTLearCarRecordsViewController.m
//  JYT_IOS
//
//  Created by nxa-chengjinhui on 2017/1/3.
//  Copyright © 2017年 nxa-yuanguoxiang. All rights reserved.
//

#import "JYTLearCarRecordsViewController.h"
#import "JYTCarRecordsTableViewCell.h"
#import "JYTCarRecondsManager.h"
#import "JYTFinishCarViewController.h"
@interface JYTLearCarRecordsViewController ()<UITableViewDelegate,UITableViewDataSource>
{
     NSMutableArray *arr;
}
@property (nonatomic,strong) UITableView *tabview;

@end

@implementation JYTLearCarRecordsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSDictionary *dic = @{@"lftBtnBgImg":@"ic_goback",
                          @"lftBtnTitle":@"no",
                          @"pageTitle":@"学车记录",
                          @"rhtBtnBgImg":@"no",
                          @"rhtBtnTitle":@"no"};
    
    [self setNavgationBarWithDic:dic];
    
    arr = [NSMutableArray array];
    
    //标题
    UILabel *headTitle = [[UILabel alloc] initWithFrame:CGRectMake(20, 64+10, CURRENT_SCREEN_WIDTH/2, 30)];
    headTitle.text = @"已完成的订单";
    headTitle.textColor = [UIColor redColor];
    headTitle.font = [UIFont boldSystemFontOfSize:16];
    headTitle.adjustsFontSizeToFitWidth = YES;
    [self.view addSubview:headTitle];
    
    //获取数据
    [self getDataSource];
    
    [self initsubview];
}

-(void)getDataSource{
    
    JYTCarRecondsManager *manager = [JYTCarRecondsManager  shareCaraReconds];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[[JYTUserManager shared] getUser].learnType  forKey:@"Subject_type"];
    [dic setObject:[[JYTUserManager shared] getUser].resId forKey:@"ResId"];
    [dic setObject:@"1" forKey:@"PageNo"];
    [dic setObject:@"10" forKey:@"PageSize"];
    
    [dic setObject:@"MyRecords" forKey:@"CommandCode"];
    
    [manager getData:dic completed:^(BOOL success) {
        if (success) {
            [self.tabview reloadData];
        }
    }];
}

-(void)initsubview{
    
    if (!self.tabview) {
        self.tabview = [[UITableView alloc] initWithFrame:CGRectMake(0, 104, CURRENT_SCREEN_WIDTH, CURRENT_SCREEN_HEIGHT-104) style:UITableViewStylePlain];
        self.tabview.delegate = self;
        self.tabview.dataSource = self;
        self.tabview.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
        [self.tabview registerNib:[UINib nibWithNibName:NSStringFromClass([JYTCarRecordsTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"recondCell"];
        [self.view addSubview:self.tabview];
    }
}

#pragma mark -----UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    JYTCarRecordsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recondCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row==1) {
        cell.payStateLab.text = @"dasdasdf";
    }
   
    [arr addObject:cell.payStateLab.text];
    return cell;
}
#pragma mark -----UITableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [self pushViewController:[[JYTFinishCarViewController alloc] initWithState:arr[indexPath.row]]];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
